package com.example.service;

import com.example.pojo.Ticket;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 服务降级
 */
@Component
public class TicketServiceFallbackFactory implements FallbackFactory {
    @Override
    public TicketFeignService create(Throwable throwable) {
        return new TicketFeignService() {
            @Override
            public List<Ticket> selectAll() {
                return null;
            }

            @Override
            public boolean insertTicket(Ticket ticket) {
                return false;
            }

            @Override
            public Ticket getTicket(Long id) {
                Ticket ticket = new Ticket();
                ticket.setId(id);
                ticket.setName("被降级");
                ticket.setDb("null");
                return ticket;
            }

//            @Override
//            public boolean deleteTicket(Long id) {
//                return false;
//            }
        };
    }
}
